package com.ruoyi.examApproval.mapper;

import com.ruoyi.examApproval.domain.Approval;
import org.apache.ibatis.annotations.*;
import java.util.List;

public interface ApprovalMapper
{
    @Select("SELECT * FROM tb_exam_approval WHERE id = #{id}")
    Approval selectApprovalById(Long id);

    @Select("SELECT * FROM tb_exam_approval WHERE candidate_id = #{candidateId}")
    Approval selectApprovalByCandidateId(String candidateId);

    @Select("SELECT * FROM tb_exam_approval")
    List<Approval> selectApprovalList();

    @Insert("INSERT INTO tb_exam_approval(candidate_id, exam_number, approval_status, approval_time, approval_comments) VALUES (#{candidateId}, #{examNumber}, #{approvalStatus}, #{approvalTime}, #{approvalComments})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertApproval(Approval approval);

    @Update("UPDATE tb_exam_approval SET candidate_id=#{candidateId}, exam_number=#{examNumber}, approval_status=#{approvalStatus}, approval_time=#{approvalTime}, approval_comments=#{approvalComments} WHERE id = #{id}")
    int updateApproval(Approval approval);

    @Delete("DELETE FROM tb_exam_approval WHERE id = #{id}")
    int deleteApprovalById(Long id);
}

